package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.EmsCombinationDetail;
import com.econ.powercloud.ems.dal.mapper.EmsCombinationDetailMapper;
import com.mysql.cj.util.StringUtils;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author : zjf
 * @Description :EmsCombinationDetail的DAO层
 * @Date : 2022/4/18 14:30
 * @Modified by : zjf
 */
@Repository
public class EmsCombinationDetailDAO extends ServiceImpl<EmsCombinationDetailMapper, EmsCombinationDetail> {

    /**
     * 通过组合id获取对应的点号详情
     */
    public List<EmsCombinationDetail> selectListByCombinationId(String combinationId){
        LambdaQueryWrapper<EmsCombinationDetail> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(!StringUtils.isNullOrEmpty(combinationId), EmsCombinationDetail::getCombinationId, combinationId);
        return this.baseMapper.selectList(lambdaQueryWrapper);
    }

    /**
     * 通过组合id删除对应的数据
     */
    public Integer deleteByCombinationId(String combinationId){
        LambdaQueryWrapper<EmsCombinationDetail> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(EmsCombinationDetail::getCombinationId, combinationId);
        return this.baseMapper.delete(lambdaQueryWrapper);
    }
}
